﻿using System.Collections.Generic;
using System.Data;

namespace personalplaner.dataprovider.common
{
	public partial class DatabaseConnectorService
	{
		internal static IEnumerable<string> m_databaseData(DataTable table)
		{
			var nameExists = table.Columns.Contains("name");

			foreach (DataRow row in table.Rows)
			{
				if (!nameExists)
					continue;
				var name = row.Field<string>("name");

				// Keine System-Datenbanken laden
				if (name != "master" && name != "model" && name != "msdb" && name != "tempdb")
					yield return name;
			}
		}

        internal static bool m_databaseIsPersonalplaner(DataTable table)
        {
            if(!table.Columns.Contains("retval"))
                return false;

            if (table.Rows.Count > 0)
            {
                return table.Rows[0].Field<string>("retval").Trim() == "1";
            }

            return false;
        }
	}
}
